#ifndef _BUOLA_WIDGETS_CTOOLBAR_H_
#define _BUOLA_WIDGETS_CTOOLBAR_H_

#include <buola/widgets/cwidget.h>

#include <buola/gui/cmenu.h>

namespace buola { namespace gui {

class CToolBar : public CWidget
{
public:
    CToolBar(PMenu pMenu=nullptr);
    ~CToolBar();

public:
    void SetMenu(PMenu);
    PMenu Menu()     {   return mMenu;   }

protected:
    void ShapeAll();
    void PosAll();

    void SelectItem(int);
    void SelectSubMenu(int);

    void ChangeSelection(int);

public:
////////////// Event handling //////////////
    virtual void OnExpose(const CExposeEvent &pE);
    virtual void OnButtonDown(const CMouseEvent &pE);
    virtual void OnButtonUp(const CMouseEvent &pE);
    virtual void OnMouseMove(const CMouseEvent &pE);
    virtual void OnMouseOut(const CMouseEvent &pE);
    virtual void OnStyleChanged(TStyle);
    virtual void OnSize(const CGeometryEvent &pE);

    void OnMenuClosed();
    void OnMenuChanged();
    void OnTimer();
protected:
    PMenu mMenu;

    int mSelected;

    int mTextX;

    PMenuBar mSubMenu;
    int mOpenSubMenu;

    bool mPressed;

    bool mTipOn;
    CTimer *mTipTimer;
    PToolTip mToolTip;

    std::vector<CSize_i> mItemSize;
    std::vector<CPoint_d> mItemPos;

    CSize_i mMaxSize;

    img::PFont mFont;
};

/*namespace gui*/ } /*namespace buola*/ }

#endif
